package com.yc.cloud.portal.controller;

import com.yc.cloud.basic.api.CommonPage;
import com.yc.cloud.basic.api.ResponseResult;
import com.yc.cloud.basic.dto.BaseQueryParam;
import com.yc.cloud.entity.AnswerRecord;
import com.yc.cloud.portal.service.AnswerRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.val;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 答题记录
 *
 * @author Yancy
 * @date 2024-04-24
 */
@RestController
@RequestMapping("/answer/record")
@Api(value = "答题记录", tags = "答题记录接口")
public class AnswerRecordController {

    @Resource
    private AnswerRecordService answerRecordService;


    @GetMapping
    @ApiOperation(value = "答题记录列表", notes = "支持分页查询,字段模糊匹配,排序等")
    public ResponseResult<CommonPage<AnswerRecord>> list(BaseQueryParam param) {
        val result = answerRecordService.list(param);
        return ResponseResult.success(CommonPage.restPage(result));
    }


    @GetMapping("{id}")
    @ApiOperation(value = "答题记录详情", notes = "根据ID查询")
    public ResponseResult<AnswerRecord> get(@PathVariable @ApiParam(value = "ID", required = true) Long id) {
        val result = answerRecordService.get(id);
        return ResponseResult.success(result);
    }


//    @PostMapping
//    @ApiOperation(value = "添加答题记录", notes = "添加")
//    public ResponseResult<AnswerRecord> create(@Validated @RequestBody AnswerRecord param) {
//        val result = answerRecordService.create(param);
//        return result != null ? ResponseResult.success(result) : ResponseResult.failed();
//    }
//
//
//    @ApiOperation(value = "删除答题记录", notes = "通过ID删除")
//    @DeleteMapping(value = "{id}")
//    public ResponseResult<Boolean> delete(@PathVariable @ApiParam(value = "ID", required = true) Long id) {
//        val result = answerRecordService.delete(id);
//        return result ? ResponseResult.success(true) : ResponseResult.failed();
//    }
//
//
//    @ApiOperation(value = "修改答题记录", notes = "通过ID修改")
//    @PutMapping(value = "{id}")
//    public ResponseResult<AnswerRecord> update(@PathVariable @ApiParam(value = "ID", required = true) Long id, @Validated @RequestBody AnswerRecord param) {
//        val result = answerRecordService.update(id, param);
//        return result != null ? ResponseResult.success(result) : ResponseResult.failed();
//    }
}
